package com.demo.study.algorithm.practice;

import org.junit.Test;

/**
 * Demo01
 *
 * @author Baymax
 * @since 2024-10-24
 */
public class Demo01 {
    @Test
    public void demo1Test() {
        System.out.println(suShuCount(100));
    }

    private int suShuCount(int num) {
        int count = 0;
        for (int i = 2; i <= num; i++) {
            count += isSuShu(i) ? 1 : 0;
        }
        return count;
    }

    private boolean isSuShu(int x) {
        for (int i = 2; i < x; i++) {
            if (x % i == 0) {
                return false;
            }
        }
        return true;
    }

    @Test
    public void demo02Test() {
        for (int i = 5; i < 5; i++) {
            System.out.println(i);
        }

        int i = 0;
        // while (i < 5) {
        //     System.out.println(i);
        //     i++;
        // }

        do {
            System.out.println(i);
            i++;
        } while (i < 5);
    }
}
